<template>
  <el-row :span="24" v-if="show" class="skeleton-contail">
    <el-col :span="item.span" v-for="(item,index) in list" :key="index" :style="{padding: item.padding}">
      <div class="content" :style="loadStyle(item)">

      </div>
    </el-col>
  </el-row>
</template>

<script>
export default {
  name: 'skeleton',
  data() {
    return {}
  },
  props: {
    list: {
      type: Array,
      default: () => []
    },
    show: {
      type: Boolean,
      default: false
    }
  },
  created() {},
  mounted() {},
  methods: {
    loadStyle(item) {
      return {
        width:
          (item.width + '').indexOf('%') != -1 ? item.width : `${item.width}px`,
        height: `${item.height}px`,
        margin: item.margin,
        borderRadius: item.type
          ? '100%'
          : (item.radius + '').indexOf('%') != -1
            ? item.radius
            : `${item.radius}px`
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.skeleton-contail {
  position: absolute;
  top: 0;
  z-index: 999999;
  width: 100%;
  height: 100%;
  background-color: #fff;
  .content {
    background-color: #f0f0f0;
    box-sizing: border-box;
  }
}
</style>
